package com.jsbs.iam.api.system.factory;


import com.jsbs.iam.api.system.RemoteAuthService;
import com.jsbs.iam.api.system.model.ApiDataReqForm;
import com.jsbs.iam.common.core.domain.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 用户服务降级处理
 * 
 * @author junwc
 */
@Component
public class RemoteAuthFallbackFactory implements FallbackFactory<RemoteAuthService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteAuthFallbackFactory.class);

    @Override
    public RemoteAuthService create(Throwable throwable)
    {
        log.error("验证服务调用失败:{}", throwable.getMessage());
        return new RemoteAuthService()
        {
            @Override
            public R checkSign(ApiDataReqForm reqForm, String source)
            {
                return R.fail("验证服务调用失败:" + throwable.getMessage());
            }
        };
    }
}
